1. The Field of the Invention
The present invention relates to the field of driver software for computer hardware. Specifically, the present invention relates to methods, systems, and computer program products that allow for a single implementation of one or more operations that are common to both kernel mode processing and user mode processing relative to the hardware adapter.
2. Background and Related Art
With the increasing performance of computer hardware, the operation of computer software is becoming a more significant factor in overall system performance. Efficient computer software for interacting with hardware adapters that communicate with hardware devices is particularly important given the frequency and amount of information that tends to be exchanged. One typical communication bottleneck relates to various software layers and the corresponding transitions between process modes that often occur between an application and a hardware adapter.
Many operating systems provide at least two process modes: (i) a relatively less trusted and therefore more restricted user mode, and (ii) a relatively more trusted and therefore less restricted kernel mode. Generally, application processes run within user mode so that the processes are isolated and cannot interfere with each other's resources. User processes switch to kernel mode when making system calls, generating an exception or fault, when an interrupt occurs, etc. Processes running in kernel mode are privileged and have access to all computer resources (such as all available memory), without the restrictions that apply to user mode processes. Because the operating system kernel acts as a gatekeeper to computer resources, direct access to resources is generally limited to kernel mode processes. Distinctions between user mode processes and kernel mode processes also may be supported by computer hardware. For example, many microprocessors have processing modes to support the distinctions between user mode processes and kernel mode processes.
Because access to certain resources is limited to kernel mode processes, a user mode process must transition or switch to a kernel mode process to gain access. Following access, the process switches back to user mode for further execution. Switching process modes, however, can have a significant impact of performance. Therefore, in an effort to alleviate the performance degradation associated with switching process modes, some hardware adapters support enforcement of security measures within certain parameters so that user mode applications may access the hardware directly, without having to transition to kernel mode. Accordingly, some software drivers bypass kernel mode for certain operations.
Despite allowing user mode processes direct access to hardware resources, the overall security of the computer system remains in tact by limiting access within specified security parameters. For the hardware adapter, these security parameters are set using kernel mode processes. Essentially, the security parameters indicate that a particular process is allowed direct access for certain operations. The hardware adapter will reject similar access attempts by other processes, and will reject access attempts by a process that are beyond the scope of permission granted by the security parameters.
Certain operations may be implemented for both user mode and kernel mode. Implementing the same operation in each mode, however, introduces inefficiencies in the software development process. Consider, for example, a memory allocation. Although in each case a region of memory is allocated, memory allocations in kernel mode have different requirements than memory allocations in user mode. For example, a kernel mode memory allocation may guarantee certain alignment conditions to facilitate hardware interaction, whereas alignment conditions may be irrelevant for a user mode memory allocation. Yet, from the perspective of a hardware driver, all that is needed is a region of memory. As a result, a single operation for accessing a hardware adapter typically has separate user mode and kernel mode implementations. Accordingly, methods, systems, and computer program products that allow for a single implementation of operations that are common to both kernel mode processing and user mode processing, relative to the hardware adapter, are desired.